package com.example.ee_demo.controller;

import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @className: HeaderController
 * @author: 芃
 * @description: 获取Header
 * @date: 2024/12/20 17:14
 */
@RequestMapping("/header")
@RestController
public class HeaderController {


    @RequestMapping("/getHeader")
    public String getHeader(HttpServletRequest request){
        String user_agent = request.getHeader("user-agent");
        String connection = request.getHeader("connection");
        System.out.println(connection);
        return user_agent;
    }

    @RequestMapping("/getHeader2")
    public String getHeader2(@RequestHeader("user-agent") String user_agent){
        return user_agent;
    }

}
